<?php
class Merchant_Model_Warehouse
{

	private $_table;
	public function __construct(){
		$this->_table = new Merchant_Model_DbTable_Warehouse();
	}


	public function add($row){
		return $this->_table->insert($row);
	}

	public  function update($row,$value,$field='wharehouse_id'){
		$where = $this->_table->getAdapter()->quoteInto("{$field} = ?",$value);
		return $this->_table->update($row, $where);

	}


	public function delete($value,$field='wharehouse_id'){

		$where = $this->_table->getAdapter()->quoteInto("{$field} = ?", $value);

		return $this->_table->delete($where);

	}


	public function getByValue($value,$field='warehouse_id'){
        $select = $this->_table->getAdapter()->select();
        $table  = $this->_table->info('name');
        $select->from($table,'*');
        $select->where("{$field} = ?",$value);
		//return $select->__toString();
		return $this->_table->getAdapter()->fetchRow($select);
	}
	public function getSetByValue($value,$field='warehouse_id'){
        $select = $this->_table->getAdapter()->select();
        $table  = $this->_table->info('name');
        $select->from($table,'*');
        $select->where("{$field} = ?",$value);
		//return $select->__toString();
		return $this->_table->getAdapter()->fetchAll($select);
	}
    
}